import { TNpc } from "../../../Message/Db/Tables/TNpc";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class NPCConfig
    
    export  class NPCConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (NPCConfig._instance != null) 
            {
                throw new Error(" ResConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TNpc();
                loc1.npcId = loc2.npcId;
                loc1.name = loc2.name;
                loc1.talk = StringHelper.getString(loc2.talk);
                loc1.avatarId = loc2.avatarId;
                loc1.modelId = StringHelper.getString(loc2.modelId);
                loc1.effectDes = StringHelper.getString(loc2.effectDes);
                loc1.career = StringHelper.getString(loc2.career);
                loc1.headId = StringHelper.getString(loc2.headId);
                loc1.title = loc2.title;
                this._map[loc1.npcId] = loc1;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_npc.json");
            this.write(loc1);
            return;
        }

        public getInfoByCode(arg1: int): TNpc
        {
            return this._map[arg1];
        }

        public static get instance(): NPCConfig
        {
            if (NPCConfig._instance == null) 
            {
                NPCConfig._instance = new NPCConfig();
            }
            return NPCConfig._instance;
        }

        public static /* const */FairyLandNpcId: int=3000020;

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: NPCConfig;
    }
